package com.ywk.pattern._15_abstractfactory._15_9;

import com.ywk.pattern._15_abstractfactory._15_4.IDepartment;
import com.ywk.pattern._15_abstractfactory._15_4.IUser;

public class DataAccess {
    public static String db = null;

    public static IUser createUser() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        String className = "com.ywk.pattern._15_abstractfactory._15_4."
                + db + "User";

        Class<IUser> iclass = (Class<IUser>) Class.forName(className);
        return iclass.newInstance();

    }

    public static IDepartment createDepartment() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        String className = "com.ywk.pattern._15_abstractfactory._15_4."
                + db + "Department";
        Class<IDepartment> iclass = (Class<IDepartment>) Class.forName(className);
        return iclass.newInstance();

    }
}
